﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using messageboard.dal;
using messageboard.bll;
using System.Data;


namespace messageboard
{
    public partial class search : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {   //分配匿名id
            if (Session["id"] == null)
            {
                Session["id"] = 1;
                Session["name"] = "匿名";
                
            }
            //_来_自_5_1_a_s_p__x
            string content = Request.QueryString["content"];//从地址栏获得查询字符串
            if (content==null)
            {
                Label1.Text = "请输入搜索内容";
            }
            else
            {   //数据绑定
                Label1.Text = content+"的搜索结果为:";
                Repeater1.DataSource = new MessageBll().searchmessagebycontent(content);
                Repeater1.DataBind();
            }

            //当前登录用户信息
            UserBll userbll = new UserBll();
            DataTable dt = userbll.getuserdetail(Session["name"].ToString());
            string name = dt.Rows[0]["name"].ToString();
            string face = dt.Rows[0]["face"].ToString();
            Label2.Text = name;                                 //用户名
            Image2.ImageUrl = "~/images/face/(" + face + ").png"; //用户头像
        }

        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {

        }
    }
}